package br.unip.tcc.domotic.orm;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "residencia")
public class Home extends AbstractORM {
	
	private static final long serialVersionUID = 1L;
	
	private Integer homeId;
	private String homeName;
	private Double homeArea;
	private HomeType homeType;
	private Set<Floor> floors = new HashSet<Floor>(0);
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "cod_residencia", unique = true, nullable = false)
	public Integer getHomeId() {
		return homeId;
	}
	
	public void setHomeId(Integer homeId) {
		this.homeId = homeId;
	}
	
	@Column(name = "nom_residencia", nullable = false)
	public String getHomeName() {
		return homeName;
	}
	
	public void setHomeName(String homeName) {
		this.homeName = homeName;
	}
	
	@Column(name = "val_area_residencia", nullable = true)
	public Double getHomeArea() {
		return homeArea;
	}
	
	public void setHomeArea(Double homeArea) {
		this.homeArea = homeArea;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cod_tipo_residencia", nullable = false)
	public HomeType getHomeType() {
		return homeType;
	}
	
	public void setHomeType(HomeType homeType) {
		this.homeType = homeType;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "home")
	public Set<Floor> getFloors() {
		return floors;
	}
	
	public void setFloors(Set<Floor> floors) {
		this.floors = floors;
	}
	
}
